var _Page;

function _defineProperty(a, t, e) {
    return t in a ? Object.defineProperty(a, t, {
        value: e,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : a[t] = e, a;
}

var app = getApp();

Page((_defineProperty(_Page = {
    data: {
        _is_load: !0,
        is_akey: !1,
        condition: !1,
        _card_info: [],
        glo_is_load: !1,
        btn_disabled: !1,
        submitIsLoading: !1,
        yzm_btn_disabled: !0,
        showView: !1,
        yzm_all_time: 60,
        _mobile: "",
        phone_yzm_code: "",
        img_index: 0,
        image_list1: [],
        tempFilePaths: [],
        img_count_limit: 12,
        this_img_i: 0,
        postImg: "",
        uploadimgArr: [],
        this_img_max: 0,
        cityaddress: "默认发布者名片的地址（可不选择）",
        industryid: 0,
        classname: "点这里选择"
    },
    onLoad: function(a) {
        var e = this;
        app.util.footer(this), app.util.getUserInfo(function(a) {
            e.setData({
                userInfo: a
            }), a.memberInfo || wx.showModal({
                title: "重要提示",
                content: "你【拒绝】了授权，不能和您一起快乐的玩耍了！请10分钟后再次点击授权，或者删除小程序重新进入，点击【允许】",
                showCancel: !1,
                success: function(a) {
                    wx.navigateBack();
                }
            });
        }), wx.login({
            success: function(a) {
                var t = a.code;
                wx.getUserInfo({
                    success: function(a) {
                        app.util.request({
                            url: "entry/wxapp/openid",
                            data: {
                                m: "bbyscm_card",
                                code: t
                            },
                            success: function(a) {
                                a.data.openid;
                                e.setData({
                                    session_key: a.data.session_key
                                });
                            }
                        });
                    }
                });
            }
        });
        var t = a.cityid;
        e.setData({
            cityid: t
        }), 0 < t && app.util.request({
            url: "entry/wxapp/GetCityxinxi",
            data: {
                m: "bbyscm_card",
                cityid: t
            },
            success: function(a) {
                0 == a.data.errno && e.setData({
                    cityxinxi: a.data.data,
                    cityname: a.data.data.cityname,
                    classname: a.data.data.classname,
                    mobilec: a.data.data.mobilec,
                    cityaddress: a.data.data.cityaddress,
                    tempFilePaths: a.data.data.imgs,
                    uploadimgArr: a.data.data.imgs,
                    cityclassid: a.data.data.cityclass,
                    _is_load: !1
                });
            }
        }), app.util.request({
            url: "entry/wxapp/GetCard",
            data: {
                m: "bbyscm_card"
            },
            success: function(a) {
                0 == a.data.errno && (a.data.data ? 0 == a.data.data.akey ? e.setData({
                    card_info: a.data.data,
                    cardid: a.data.data.id,
                    avater: a.data.data.avater,
                    mobile: a.data.data.mobile,
                    cardname: a.data.data.cardname,
                    longitude: a.data.data.longitude,
                    latitude: a.data.data.latitude,
                    cityaddress: a.data.data.address,
                    province: a.data.data.province,
                    city: a.data.data.city,
                    county: a.data.data.county,
                    akey: a.data.data.akey,
                    _is_load: !1
                }) : e.setData({
                    _is_load: !1,
                    is_akey: !0
                }) : (wx.showModal({
                    title: "提示",
                    content: "你还没有创建名片，不能发布",
                    confirmText: "创建名片",
                    success: function(a) {
                        a.confirm ? wx.navigateTo({
                            url: "../../card/edit/card-edit"
                        }) : a.cancel && wx.navigateBack();
                    }
                }), e.setData({
                    _is_load: !1,
                    no_card: !0
                })));
            }
        }), app.util.request({
            url: "entry/wxapp/Setup",
            data: {
                m: "bbyscm_card"
            },
            success: function(a) {
                e.setData({
                    setup: a.data.data,
                    apikey: a.data.data.apikey
                });
            }
        }), app.util.request({
            url: "entry/wxapp/GetCityclass",
            data: {
                m: "bbyscm_card"
            },
            success: function(a) {
                e.setData({
                    cityclass: a.data.data
                }), e.setData({
                    currentTabmenu: 1,
                    _is_load: !1
                });
            }
        });
    },
    open_map_chonse: function() {
        var t = this;
        wx.chooseLocation({
            type: "gcj02",
            success: function(a) {
                t.setData({
                    longitude: a.longitude,
                    latitude: a.latitude,
                    cityaddress: a.address
                });
            },
            fail: function(a) {
                t.setData({
                    fail2: !0
                });
            },
            complete: function(a) {
                new (require("../../../utils/qqmap-wx-jssdk.js"))({
                    key: t.data.apikey
                }).reverseGeocoder({
                    location: {
                        latitude: t.data.latitude,
                        longitude: t.data.longitude
                    },
                    success: function(a) {
                        t.setData({
                            region: a.result.address_component,
                            province: a.result.address_component.province,
                            city: a.result.address_component.city,
                            county: a.result.address_component.district,
                            street_title: a.result.address_reference.town.title,
                            street_number: a.result.address_component.street_number,
                            recommend: a.result.formatted_addresses.recommend
                        });
                    },
                    fail: function(a) {},
                    complete: function(a) {}
                });
            }
        });
    },
    onShareAppMessage: function() {},
    onReady: function() {},
    onShow: function() {
        var a = this, t = a.data.cityid;
        a.setData({
            yzm_all_time: 60,
            cityid: t,
            avater: a.data.userInfo.memberInfo.avatar
        });
    },
    imgDel: function(a) {
        var t = this, e = a.currentTarget.id, i = t.data.tempFilePaths, s = t.data.uploadimgArr;
        i.splice(e, 1), s.splice(e, 1), t.setData({
            tempFilePaths: i,
            uploadimgArr: s
        });
    },
    previewImage: function(a) {
        wx.previewImage({
            current: a.target.dataset.url,
            urls: [ a.target.dataset.url ]
        });
    },
    upload_img: function(s, n) {
        s.setData({
            hidden: !1
        });
        var a = app.util.url("entry/wxapp/WxUpload");
        wx.uploadFile({
            url: a + "m=bbyscm_card",
            filePath: n,
            name: "file",
            success: function(a) {
                var t = a.data;
                if ("string" == typeof t && (t = JSON.parse(t.trim())), 0 == t.errno) {
                    var e = new Array(), i = new Array();
                    (i = s.data.uploadimgArr).push(t.data), (e = s.data.tempFilePaths).push(n), s.setData({
                        uploadimgArr: i,
                        tempFilePaths: e
                    }), s.data.img_index = s.data.img_index + 1, s.data.img_index < s.data.image_list1.length ? s.upload_img(s, "" + s.data.image_list1[s.data.img_index]) : s.setData({
                        hidden: !0
                    });
                } else s.setData({
                    hidden: !0
                });
            },
            fail: function(a) {
                s.setData({
                    hidden: !0
                });
            }
        });
    },
    addimg: function() {
        var e = this;
        e.data.tempFilePaths.length < 9 ? wx.chooseImage({
            count: 9 - e.data.tempFilePaths.length,
            sizeType: [ "compressed" ],
            sourceType: [ "album", "camera" ],
            success: function(a) {
                e.data.image_list1 = new Array();
                for (var t = 0; t < a.tempFilePaths.length; t++) e.data.image_list1.push(a.tempFilePaths[t]);
                e.upload_img(e, "" + e.data.image_list1[0]);
            },
            fail: function() {
                wx.showToast({
                    title: "选取失败",
                    icon: "success",
                    duration: 2e3
                });
            }
        }) : wx.showToast({
            title: "当前最多只能选择9张图片",
            icon: "success",
            duration: 1e4
        });
    },
    postCard: function(a) {
        var t = this;
        t.setData({
            btn_disabled: !0,
            submitIsLoading: !0
        }), JSON.stringify(a.detail.value);
        var e = a.detail.formId, i = t.data.cityid, s = t.data.cardname, n = a.detail.value.cardnamec, d = t.data.mobile, c = a.detail.value.mobilec, o = a.detail.value.cityname, r = t.data.cardid, l = t.data.cityaddress, u = t.data.paymoney, m = t.data.cityclassid, p = a.detail.value.citydesc, y = t.data.longitude, f = t.data.latitude, g = t.data.province, _ = t.data.city, w = t.data.county, h = t.data.street_title, x = t.data.street_number, b = t.data.userInfo.memberInfo.avatarUrl, v = t.data.uploadimgArr;
        if (v = v.join("|"), !o) return wx.showModal({
            title: "提示",
            content: "请输入信息标题",
            showCancel: !1,
            success: function(a) {
                a.confirm, t.setData({
                    btn_disabled: !1,
                    submitIsLoading: !1
                });
            }
        }), !1;
        if (!m) return wx.showModal({
            title: "提示",
            content: "请选择信息类别",
            showCancel: !1,
            success: function(a) {
                a.confirm, t.setData({
                    btn_disabled: !1,
                    submitIsLoading: !1
                });
            }
        }), !1;
        if (n) n = n; else var n = s;
        if (c) c = c; else var c = d;
        if (0 < u) if (u > t.data.card_info.money) {
            var P = (u - t.data.card_info.money).toFixed(2), D = (u - P).toFixed(2);
            wx.showModal({
                title: "提示",
                content: "发布此信息应支付" + u + "元，实支付" + P + "元，扣除帐户余额" + D + "元",
                confirmText: "确认支付",
                showCancel: !1,
                success: function(a) {
                    a.confirm && app.util.request({
                        url: "entry/wxapp/Pay",
                        data: {
                            m: "bbyscm_card",
                            cost: P,
                            id: i
                        },
                        method: "POST",
                        success: function(a) {
                            wx.requestPayment({
                                timeStamp: a.data.timeStamp,
                                nonceStr: a.data.nonceStr,
                                package: a.data.package,
                                signType: a.data.signType,
                                paySign: a.data.paySign,
                                success: function(a) {
                                    t.setData({
                                        Msg: a.errMsg,
                                        pay: !1
                                    }), "requestPayment:ok" == t.data.Msg && (wx.showToast({
                                        title: "提交中...",
                                        icon: "loading",
                                        duration: 1e4
                                    }), app.util.request({
                                        url: "entry/wxapp/PostWordspay",
                                        data: {
                                            m: "bbyscm_card",
                                            cardid: r,
                                            wordsid: i,
                                            pay_class: 5,
                                            coll: u
                                        },
                                        method: "POST"
                                    }), app.util.request({
                                        url: "entry/wxapp/PostCityxinxi",
                                        data: {
                                            m: "bbyscm_card",
                                            form_id: e,
                                            cityid: i,
                                            cityname: o,
                                            cardid: r,
                                            cardname: s,
                                            cardnamec: n,
                                            mobile: d,
                                            mobilec: c,
                                            cityaddress: l,
                                            citydesc: p,
                                            longitude: y,
                                            latitude: f,
                                            province: g,
                                            city: _,
                                            county: w,
                                            street_title: h,
                                            street_number: x,
                                            cityclass: m,
                                            avaterImg: b,
                                            imgs: v,
                                            yepay_coll: D
                                        },
                                        method: "POST",
                                        success: function(a) {
                                            0 == a.data.errno ? (app.util.request({
                                                url: "entry/wxapp/Message1",
                                                data: {
                                                    m: "bbyscm_card",
                                                    openid: t.data.card_info.openid,
                                                    form_id: e,
                                                    pay_class: 5,
                                                    pay_classid: r,
                                                    coll: u,
                                                    cardname: s,
                                                    page: "pages/city/index/index"
                                                },
                                                success: function(a) {
                                                    wx.reLaunch({
                                                        url: ""
                                                    });
                                                }
                                            }), wx.showModal({
                                                title: "提示",
                                                content: "提交成功",
                                                showCancel: !1,
                                                success: function(a) {
                                                    wx.navigateBack();
                                                }
                                            })) : wx.showModal({
                                                title: "提示",
                                                content: a.data.message,
                                                showCancel: !1,
                                                success: function(a) {
                                                    a.confirm;
                                                }
                                            });
                                        },
                                        fail: function(a) {
                                            wx.showModal({
                                                title: "提示",
                                                content: a.data.message,
                                                showCancel: !1,
                                                success: function(a) {
                                                    a.confirm;
                                                }
                                            });
                                        },
                                        complete: function() {
                                            wx.hideToast();
                                        }
                                    }));
                                },
                                fail: function(a) {
                                    t.setData({
                                        pay: !1,
                                        btn_disabled: !1,
                                        submitIsLoading: !1,
                                        videopay: !1
                                    }), wx.showToast({
                                        title: "支付失败",
                                        duration: 1e3
                                    });
                                }
                            });
                        }
                    });
                }
            });
        } else {
            D = u;
            wx.showModal({
                title: "提示",
                content: "发布此信息应支付" + u + "元，扣除帐户余额" + D + "元",
                confirmText: "确认",
                showCancel: !1,
                success: function(a) {
                    a.confirm && (wx.showToast({
                        title: "提交中...",
                        icon: "loading",
                        duration: 1e4
                    }), app.util.request({
                        url: "entry/wxapp/PostCityxinxi",
                        data: {
                            m: "bbyscm_card",
                            form_id: e,
                            cityid: i,
                            cityname: o,
                            cardid: r,
                            cardname: s,
                            cardnamec: n,
                            mobile: d,
                            mobilec: c,
                            cityaddress: l,
                            citydesc: p,
                            longitude: y,
                            latitude: f,
                            province: g,
                            city: _,
                            county: w,
                            street_title: h,
                            street_number: x,
                            cityclass: m,
                            avaterImg: b,
                            imgs: v,
                            yepay_coll: D
                        },
                        method: "POST",
                        success: function(a) {
                            0 == a.data.errno ? wx.showModal({
                                title: "提示",
                                content: "提交成功",
                                showCancel: !1,
                                success: function(a) {
                                    wx.navigateBack();
                                }
                            }) : wx.showModal({
                                title: "提示",
                                content: a.data.message,
                                showCancel: !1,
                                success: function(a) {
                                    a.confirm;
                                }
                            });
                        },
                        fail: function(a) {
                            wx.showModal({
                                title: "提示",
                                content: a.data.message,
                                showCancel: !1,
                                success: function(a) {
                                    a.confirm;
                                }
                            });
                        },
                        complete: function() {
                            wx.hideToast();
                        }
                    }));
                }
            });
        } else wx.showToast({
            title: "提交中...",
            icon: "loading",
            duration: 1e4
        }), app.util.request({
            url: "entry/wxapp/PostCityxinxi",
            data: {
                m: "bbyscm_card",
                form_id: e,
                cityid: i,
                cityname: o,
                cardid: r,
                cardname: s,
                cardnamec: n,
                mobile: d,
                mobilec: c,
                cityaddress: l,
                citydesc: p,
                longitude: y,
                latitude: f,
                province: g,
                city: _,
                county: w,
                street_title: h,
                street_number: x,
                cityclass: m,
                avaterImg: b,
                imgs: v
            },
            method: "POST",
            success: function(a) {
                0 == a.data.errno ? wx.showModal({
                    title: "提示",
                    content: "提交成功",
                    showCancel: !1,
                    success: function(a) {
                        wx.navigateBack();
                    }
                }) : wx.showModal({
                    title: "提示",
                    content: a.data.message,
                    showCancel: !1,
                    success: function(a) {
                        a.confirm;
                    }
                });
            },
            fail: function(a) {
                wx.showModal({
                    title: "提示",
                    content: a.data.message,
                    showCancel: !1,
                    success: function(a) {
                        a.confirm;
                    }
                });
            },
            complete: function() {
                wx.hideToast();
            }
        });
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {}
}, "onShareAppMessage", function() {}), _defineProperty(_Page, "cityclassid", function(a) {
    a.target.dataset.id;
    this.setData({
        condition: !this.data.condition,
        cityclassid: a.target.dataset.id,
        classname: a.target.dataset.name,
        paymoney: a.target.dataset.paymoney
    });
}), _defineProperty(_Page, "open", function() {
    this.setData({
        condition: !this.data.condition
    });
}), _defineProperty(_Page, "onNavigateTap", function(a) {
    wx.openSetting({});
    this.setData({
        fail2: !1
    });
}), _Page));